package me.jessyan.armscomponent.app.mvp.ui.activity.mine;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import org.jetbrains.annotations.NotNull;

import javax.inject.Inject;

import butterknife.BindView;
import me.jessyan.armscomponent.commonres.utils.ProgressDialogUtil;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.app.R;
import me.jessyan.armscomponent.app.di.component.DaggerMineCollectionComponent;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineCollectionContract;
import me.jessyan.armscomponent.app.mvp.presenter.mine.MineCollectionPresenter;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * <p>
 * Author: Taozebi
 * Date: 09/09/2021 20:16
 * Description: 收藏
 */
@Route(path = RouterHub.MINE_COLLECTIONACTIVITY)
public class MineCollectionActivity extends BaseActivity<MineCollectionPresenter> implements MineCollectionContract.View {

    @BindView(R.id.mine_rv_collection)
    public RecyclerView mine_rv_collection;

    @Inject
    RecyclerView.LayoutManager mLayoutManager;
    @Inject
    RecyclerView.Adapter mAdapter;

    @Override
    public void setupActivityComponent(@NotNull @NonNull AppComponent appComponent) {
        DaggerMineCollectionComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }


    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.mine_activity_collection; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        loadTitle();
        initRecyclerView();
        mine_rv_collection.setAdapter(mAdapter);
    }

    /**
     * 初始化RecyclerView
     */
    private void initRecyclerView() {
        ArmsUtils.configRecyclerView(mine_rv_collection, mLayoutManager);
    }

    @Override
    public void showLoading() {
        ProgressDialogUtil.show(this,"","加载中...");
    }

    @Override
    public void hideLoading() {
        ProgressDialogUtil.dismiss();
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    private void loadTitle() {
        setTitle("收藏");
    }

    @Override
    public Activity getActivity() {
        return this;
    }
}
